/* 
 * Copyright 2010 Ziya Guven Koylu, Ozge Koylu
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.koylu.caffein.model.clazz;

import java.sql.Connection;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Vector;

import com.koylu.caffein.model.caffein.CaffeinConfig;

public abstract class Relation implements Field{
	protected static Map<String, Class<?>> collectionTypes;
	static{
		collectionTypes = new HashMap<String, Class<?>>();
		collectionTypes.put(List.class.getName(), ArrayList.class);
		collectionTypes.put(AbstractList.class.getName(), ArrayList.class);
		collectionTypes.put(ArrayList.class.getName(), ArrayList.class);
		collectionTypes.put(LinkedList.class.getName(), LinkedList.class);
		collectionTypes.put(Vector.class.getName(), Vector.class);
		collectionTypes.put(Set.class.getName(), HashSet.class);
		collectionTypes.put(HashSet.class.getName(), HashSet.class);
		collectionTypes.put(TreeSet.class.getName(), TreeSet.class);
		collectionTypes.put(LinkedHashSet.class.getName(), LinkedHashSet.class);
	}	
	public abstract String getClazz();
	public abstract Clazz getForeignClazz(CaffeinConfig caffeinConfig) throws Exception;
	public abstract Class<?> getProxyClass(CaffeinConfig caffeinConfig) throws Exception;
	public abstract String getCascade();
	public abstract void save(CaffeinConfig caffeinConfig, Connection connection, Object object) throws Exception;
	public abstract void update(CaffeinConfig caffeinConfig, Connection connection, Object object) throws Exception;
	public abstract void delete(CaffeinConfig caffeinConfig, Clazz clazz, Connection connection, Object object) throws Exception;
}